package com.woniuxy.api;

import com.woniuxy.common.Result;
import com.woniuxy.form.UserCouponForm;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient(value = "coupon",contextId = "couponUser")
public interface UserCouponApi {
    /**
     * 用户新增优惠券
     * @param userCouponForm
     */
    @PostMapping("/addUserCoupon")
    Result addUserCoupon(@RequestBody UserCouponForm userCouponForm);

    /**
     * 进入订单页自动选择最优解的优惠券
     * @param userId
     * @param price
     * @return
     */
    @GetMapping("/useCouponGetPrice")
    Result useCoupon(int userId,double price);

    /**
     * 用户积分兑换优惠券
     * @param form
     * @return
     */
    @PostMapping("/exchangeCoupons")
    Result exchangeCoupons(@RequestBody UserCouponForm form);

    /**
     * 用户使用指定的优惠券
     * @param couponId
     * @param price
     * @return
     */
    @DeleteMapping("/useCoupon")
    Result userDesignatedCoupon(@RequestParam("couponId") int couponId,@RequestParam("price") double price,@RequestParam("userId") int userId);

    /**
     * 查询用户拥有的优惠券
     * @return
     */
    @GetMapping("/findUserCoupon")
    Result findUserCoupon(@RequestParam("userId") int userId);

    /**
     * 秒杀
     * @param userId
     * @param couponId
     * @return
     */
    @PostMapping("/spike")
    Result spike(@RequestParam("userId") int userId,@RequestParam("couponId") int couponId);

    /**
     * 生成秒杀token
     * @param couponId
     * @param tokenQuantity
     * @return
     */
    @PostMapping("/addSpikeToken")
    Result addSpikeToken(@RequestParam("couponId") int couponId,@RequestParam("tokenQuantity") int tokenQuantity);
}
